#include<iostream>
using namespace std;
typedef int feet;

namespace test1 {
	enum color {
		red,
		green = 5,
		blue
	} c;

	void typeCast() {
		int i = 10;
		float f = static_cast<float>(i);
		cout << ": " << f << endl;
	}

	class BaseDriver {
		virtual void test() {};
	};
	class CarDriver : public BaseDriver {
	public:
		void test() {
			printf("1\n");
		}
	};
	class CarDriver2 : public BaseDriver {
	public:
		void test() {
			printf("2\n");
		}
	};

	void typeCast2() {
		BaseDriver* bd = new CarDriver2;
		CarDriver2* cd = dynamic_cast<CarDriver2*>(bd);
		cd->test();
	}

	void constCast() {
		const int i = 10;
		int& j = const_cast<int&>(i);
		j = 11;
		cout << j << endl;
	}

	void reinterpretCast() {
		int i = 9;
		float f = reinterpret_cast<float&>(i);
		cout << f << endl;
		cout << (f + 1.1) << endl;
	}

	void reinterpretCast2() {
		int numbers[] = { 1, 2, 3, 4, 5 };
		int* pint = numbers; // 指向int数组的指针  

		// 使用reinterpret_cast将int*转换为char*  
		// 这允许我们以字节为单位访问数组的内存  
		char* pchar = reinterpret_cast<char*>(pint);

		// 遍历数组的内存，以字符（字节）为单位  
		for (size_t i = 0; i < sizeof(numbers); ++i) {
			std::cout << static_cast<int>(*(pchar + i)) << " "; // 注意：这里为了演示我们再次转换回int，但通常你会按字节处理  
		}
	}

	int main3() {
		reinterpretCast2();
		return 0;
	}


	void enumTest() {
		c = blue;
		cout << c << endl;
	}

	int func1() {
		feet x = 1;
		char y = 2;
		cout << "x + y = " << (x + y) << endl;
		return 0;
	}
}